﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

/// <summary>
/// Summary description for clsAcount
/// </summary>
public class clsAcount:clsConnection
{

    string _user = "";
    string _pass = "";
    private string _tableName = "";
    public clsAcount(string user, string pass)
	{
        _user = user;
        _pass = pass;
        _tableName = "quantri";
	}
    public clsAcount()
    {
      
        _tableName = "quantri";
    }
    //0:Sai; 1: User 2: Admin
    public int checkAcount()
    {
        _user = _user.Replace("'", "");
        _user = _user.Replace("(", "");
        _user = _user.Replace(")", "");
        _user = _user.Replace("or", "");
        clsTableAction clsTable = new clsTableAction("quantri");
        string cri = string.Format(" MaUS='{0}' and MatKhau='{1}'", _user, _pass);
        SqlDataReader sqlDare = clsTable.exportDataReader("Quyen", cri);
        int n = 0;
        if (sqlDare.Read())
            n= Convert.ToInt32(sqlDare[0]);
        else
            n= 0;

        clsTable.free();
        return n;
    }
    public Boolean addtk(string[] arrValues ,out int kq)
    {
        kq = 0;
        if (arrValues.Length != 3) return false;
        string sql = string.Format("insert into " + _tableName + " values('{0}',N'{1}','{2}''{3}')", arrValues[0], arrValues[1], arrValues[2], arrValues[3]);
        return (runSQL(sql, out kq));
        //return (runSQL(sql));
    }

}